﻿namespace XmlVisualizer
{
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Collections.Specialized;
    using System.Diagnostics;
    using System.Globalization;
    using System.IO;
    using System.Text;
    using System.Threading;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    using System.Windows.Threading;
    using System.Xml;
    using System.Xml.XPath;

    using Tomers.WPF.Localization;
    using XmlVisualizer;
    using XmlVisualizer.Exceptions;
    using XmlVisualizer.Models;

    /// <summary>
    /// Static startup class containing Main.
    /// </summary>
    public class Startup
    {
        private static App app;

        /// <summary>
        /// Main function.
        /// </summary>
        /// <param name="args">command line arguments.</param>
        [STAThread]
        public static void Main(string[] args)
        {
            try
            {
                StringCollection languages = Properties.Settings.Default.languages;

                foreach (string lang in languages)
                {
                    LanguageDictionary.RegisterDictionary(
                        CultureInfo.GetCultureInfo(lang),
                        new XmlLanguageDictionary("Localization/Languages/" + lang + ".xml"));
                }

                LanguageContext.Instance.Culture = CultureInfo.GetCultureInfo(Properties.Settings.Default.language);

                app = new App();
                app.Run();
            }
            catch (Exception ex)
            {
                Exceptions.ExceptionHandling.HandleException(ex);
            }
        }
    }
}